home *** CD-ROM | disk | FTP | other *** search
- Path: news.mcs.net!not-for-mail
- From: maney@MCS.COM (Martin J. Maney)
- Newsgroups: comp.lang.c++
- Subject: Re: Name-mangling standard
- Date: 12 Jan 1996 13:09:21 -0600
- Organization: MCSNet Services
- Message-ID: <4d6bl1$1gh@Venus.mcs.com>
- References: <20c.32169.607@newage.com.ar> <4bsnbu$5mu@mujibur.inmind.com> <30EDC013.7C780E5E@cims.nyu.edu> <DL1pqE.KKq@infosoft.com>
- NNTP-Posting-Host: venus.mcs.com
- X-Newsreader: TIN [version 1.2 PL2 (KSD)]
-
- [I'm honoring the Followup-To John set, but that means that I won't see
- replies to this. If anyone wants to discuss this with me I'm afraid
- you'll have to use e-mail. maney@mcs.com]
-
- John Galt (jgalt@infosoft.com) wrote:
- [John didn't write this next bit]:
- > > I certainly hope not! Name mangling is a solution to passing type
- > > information to 1950's linkers. Once linkers become more sophisticated,
- > > name mangling can disappear back into the slime from which it came.
-
- Observe the phrase "linkers become more sophisticated". This is an old
- idea that we may hope will someday come to pass, that linkers might learn
- that there is more to a function than a single text label. And so...
-
- > I beg to differ. Name mangling serves several indispensible functions:
-
- > 1. It makes it possible to have more than one function with the same name
- > (differing in their argument lists). To do this without mangling, the linker
- > would have to see not just a function name, or even class::name, but a full
- > _prototype_ for each function (omitting variable names and the result type).
-
- Yep, that's exactly what a more sophisticated linker might do. It might
- do even more; it would, in any case, make this information available for
- all other tools in a consistent form. There may be reasons to dislike
- this, but your notion that it would break overloading simply misses the boat.
-
- > 2. It allows the linker to do error checking. Example: Module A calls
- > foo() in module B. I change the definition of foo (and its argument list)
- > but forget to change A. Without name mangling, the program will simply crash
- > (or do strange things because I've clobbered the stack...)
-
- Ditto. (comparing signatures is the same mechanism whether it's
- resolving overloading or testing consistency. two sides of the same coin.)
-
- > On systems like the PC, with multiple pointer formats, this could also be
- > used to check that all modules (including library code) were compiled with
- > the same (or compatible) memory model. I think it is really stupid that none
- > of the compilers for the PC makes this possible by including the memory model
- > in mangled names.
-
- This would be an argument in favor of replacing name mangling with a
- smarter linker, if anything: a smart linker for a multi-model machine
- should certainly include such checking. FWIW, the late, lamented Zortech
- compiler - the real one, before Symantec bought the name - DID
- incorporate near/far and other 80x86-specific stuff into its mangled
- names. Guess it's still ahead of the competition in some respects. Not
- bad for a product that's been "dead" for so many years! :-)
-
- > 3. When linking with other languages such as Pascal, it in effect checks that
- > you told the C++ compiler to use the calling sequence for the language that
- > the function you're calling is in.
-
- Ditto re: smarter linkers.
-
- > In short, wanting to eliminate name mangling is like wanting a compiler that
- > never prints error messages. It's for people who would rather walk off a
- > cliff than have someone tell them they're about to.
-
- Since all I'm certain I've seen of the article to which you're replying
- is the scrap you quoted, it's barely possible that the author HAD meant
- something awful like this, but I doubt it. The idea of teaching linkers
- to deal with the signatures of functions more directly and thus obsoleting
- the name mangling kluge isn't new. Why, I believe Stroustrup made
- passing mention of it all the way back in the first edition.
-
-